package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.FinancingProductService;
import service.impl.FinancingProductServicImpl;

/**
 * Servlet implementation class DeleteFinProServelet
 */
@WebServlet("/DeleteFinProServelet")
public class DeleteFinProServelet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeleteFinProServelet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		String id =request.getParameter("pid"); //获取前端的参数
		System.out.println("id---: "+ id);
		
		//调用service方法执行删除
		FinancingProductService fpService = new FinancingProductServicImpl();
		
		//按 id (产品代码) 进行删除
		int res =1;// fpService.deleteFinProById(id);//1  0
		
		PrintWriter out = response.getWriter();
		out.print("{\"msg\":"+res+"}"); //  {"msg":res }
		out.flush();
		out.close();
		//页面跳转的代码千万千万不要有啊!!!
		//response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
